Rearrange array elements such that Bitwise AND of first N – 1 elements is equal to last element
Given an array arr[] of N positive integers, the task is to find an arrangement such that Bitwise AND of the first N – 1 elements is equal to the last element. If no such arrangement is possible then output will be -1.Examples:...
read more
Count all substrings having character K
Given a string str and a character K, the task is to find the count of all the substrings of str that contain the character K.Examples:...
read more
Check whether bitwise AND of N numbers is Even or Odd
Given an array arr[] containing N numbers. The task is to check whether the bitwise-AND of the given N numbers is even or odd.Examples:...
read more
Probability of getting two consecutive heads after choosing a random coin among two different types of coins
Given two coins which have probability of getting heads p% and q% respectively, the task is to determine the probability of getting two consecutive heads after choosing random coins among the given coins.Examples:...
read more
Sorting algorithm visualization : Heap Sort
An algorithm like Heap sort can be understood easily by visualizing. In this article, a program that visualizes the Heap Sort Algorithm has been implemented....
read more
Minimize sum by dividing all elements of a subarray by K
Given an array arr[] of N integers and a positive integer K, the task is to minimize the sum of the array elements after performing the given operation atmost one time. The operation is to choose a subarray and divide all elements of the subarray by K. Find and print the minimum possible sum.Examples:...
read more
P, NP, CoNP, NP hard and NP complete | Complexity Classes
In computer science, there exist some problems whose solutions are not yet found, the problems are divided into classes known as Complexity Classes. In complexity theory, a Complexity Class is a set of problems with related complexity. These classes help scientists to group problems based on how much time and space they require to solve problems and verify the solutions. It is the branch of the theory of computation that deals with the resources required to solve a problem....
read more
Solving Homogeneous Recurrence Equations Using Polynomial Reduction
A recurrence relation is an equation that recursively defines a sequence or multidimensional array of values, once one or more initial terms are given; each further term of the sequence or array is defined as a function of the preceding terms. Below are the steps required to solve a recurrence equation using the polynomial reduction method:...
read more
Time and Space Complexity Analysis of Binary Search Algorithm
Time complexity of Binary Search is O(log n), where n is the number of elements in the array. It divides the array in half at each step. Space complexity is O(1) as it uses a constant amount of extra space....
read more
Extended Disjoint Set Union on Trees
Prerequisites: DFS, Trees, DSUGiven a tree with of N nodes from value 1 to N and E edges and array arr[] which denotes number associated to each node. You are also given Q queries which contains 2 integers {V, F}. For each query, there is a subtree with vertex V, the task is to check if there exists count of numbers associated with each node in that subtree is F or not. If yes then print True else print False.Examples:...
read more
Design Classes
The Requirements Model defines a set of analysis classes. Each describes some element of the problem domain, focus on an aspect of the problem that is visible. The level of abstraction of the analysis class is comparatively high. The set of design classes refine analysis classes and providing design detail that enables classes to execute a software infrastructure that supports business solutions....
read more
Count of subsequences whose product is a difference of square of two integers
Given an array arr[] containing N elements that contain both positive and negative elements, the task is to find the total number of contiguous subsequences whose product can be expressed as the difference of the square of two integers....
read more